MBasic: Questions and Answers
Questions and Answers These questions and answers summarize points discussed in the text. How do I start the BasicATOM Pro’s program running? If you’ve already downloaded the program, just connect the power or press the RESET button on the development board. If you’re compiling a program using the Program button in the IDE, it will start running as soon as the download is complete. If you're compiling a program using the Debug button in the IDE, it will start when you press the RUN button. How can I run my program a second time with out re-compiling it? Once your program ends, the Atom Pro goes to "sleep" and no longer responds to commands. Press the RESET button on the development board, or turn the power OFF and back ON again to re-run your program. Do I lose my program if I disconnect the power from the BasicATOM Pro? No. Your program is stored in semi-permanent "flash" memory and will be retained until it’s overwritten by a new program. Once I’ve compiled a program can I use the object code to program many BasicATOM Pros? Although the object code is saved on your PC, it can’t be re-used. Just re-compile the source program for each BasicATOM Pro you want to program. Once I compile "traffic.bas" I see the files "traffic.bin" and "traffic.pdb" in the same directory. What are they? These are files generated by the compiler; "traffic.bin" is the compiled object code that’s downloaded to the BasicATOM Pro, and "traffic.pdb" is a file used in debugging. You can safely delete both of these files once everything’s working. What’s the difference between the 24, 28 and 40 pin BasicATOM Pro modules? Mainly in the number and type of I/O pins. See the table on page 5 as well as the data sheets for more information. The 24 pin Atom Pro also has the analog pins available as solder pads rather than connected to pins. Can I build my own board for a BasicATOM Pro module? Yes. You might consider using a development board for designing your project and programming the BasicATOM Pro module. Then just transfer the programmed module to your own circuit. This has the added advantage that you don’t need to include RS-232 circuitry on your project board. When I define variables, how are they allocated in memory? Variables are allocated sequential memory space, in the order in which they are defined. For example, if you define byte variables as follows: a var byte b var byte c var byte they will occupy three successive bytes in memory. Tell me more about arrays. Arrays in Atom Basic are simply a series of bytes, words, etc. assigned in sequence. For example, if you define an array as a var byte(10) this will set aside 10 sequential memory locations, numbered 0 to 9. If you subsequently define another variable, it will be assigned the next sequential memory location. So b var byte will assign b to the 11th memory location following a(0). In fact, you can actually access "b" as "a(10)" since Atom Basic doesn't check for out of range array subscripts. Does that mean that array and simple variables can overlap? Yes, depending on how the variables are defined. For simplicity, let's assume that we're using byte variables, and we define a, b, c, d and e as successive byte variables. You can now actually access, say, "c" as "a(2)" even though "a" was not defined as an array. Be careful doing this if your variables aren't all of the same type: it could get confusing. Can you suggest any use for the above? Yes, there are many possibilities. One example would be to output a number of variables by "pretending" that they are an array. So if we had the same five variables (a, b, c, d, e) as defined in the previous answer, they could be output with a single statement such as: hserout str a\5 ''Note: The values will be output in numeric form without conversion to ASCII characters.'' How do I find out more technical information about the Atom Pro? Hardware technical information is can be found on the Atom Pro 24, 28 or 40 pin module data sheets. These are available online at http://www.basicmicro.com or may be ordered from Basic Micro. Detailed hardware, feature and programming information can be found in the H8/3664F or H8/3687F hardware manuals. Both are available online at http://www.renesas.com By a careful comparison among Atom BASIC commands, and the Atom Pro and PIC data sheets, you can learn a great deal about how the Atom Pro works. Atom BASIC doesn't have a command to do exactly what I need. Can I address the microcontroller directly? Yes. Atom BASIC includes pre-defined variables that let you access the microcontroller's registers directly. These registers are bit mapped so you should be familiar with this type of operation before attempting to use registers. The use of registers directly is for advanced programmers only. ''Important: Be sure you are thoroughly familiar with the operation of the microcontroller before trying to manipulate registers directly. Basic Micro neither documents nor supports (via technical support) such operation.''